package prototype.demo2;

public class Test2 {
    public static void main(String[] args) throws CloneNotSupportedException {

        // 创建引用对象，并赋予值
        People people = new People();
        people.setName("xiangjiao");

        // 创建原型对象，并给其设定People类型值
        Realizetype2 realizetype2 = new Realizetype2();
        realizetype2.setPeople(people);

        // 克隆新对象
        Realizetype2 clone = realizetype2.clone();
        // 获取克隆对象中的 People 对象
        People people1 = clone.getPeople();
        // 将name参数值变更
        people1.setName("banana");

        // 打印People类型数据值
        System.out.println(realizetype2.getPeople().getName());
        System.out.println(clone.getPeople().getName());
    }
}
